from django.http import HttpResponse
from django.conf import settings
from jinja2 import FileSystemLoader, Environment

def render_to_response(filename, context={},mimetype=settings.DEFAULT_CONTENT_TYPE):
    env = Environment(loader=FileSystemLoader(settings.TEMPLATE_DIRS))
    template = env.get_template(filename)
    rendered = template.render(**context)
    return HttpResponse(rendered,mimetype=mimetype)